package com.igeek.service;

import com.igeek.dao.UserDao;
import com.igeek.domain.User;
import com.igeek.utils.MD5Utils;

/**
 * @author jerryHe
 * @create 2019-10-08 16:46
 */
public class UserService {
    UserDao userDao = new UserDao();

    public boolean checkActiveCode(String activeCode) {
        return userDao.checkActiveCode(activeCode);
    }

    public boolean checkUsername(String username) {
        return userDao.checkUsername(username);
    }

    public boolean login(User user) {
        //密码MD5加密
        String pwd = user.getPassword();
        String encodePwd = MD5Utils.enCode(pwd);
        user.setPassword(encodePwd);
        System.out.println(encodePwd);
        return  userDao.login(user);
    }

    public void regist(User user) {
        //密码MD5加密
        String pwd = user.getPassword();
        String encodePwd = MD5Utils.enCode(pwd);
        user.setPassword(encodePwd);

        userDao.regist(user);
    }

    public void updateActiveCode(String activeCode) {
        userDao.updateActiveCode(activeCode);
    }
}
